package com.isorf.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.isorf.mapper.linkmapper;
import com.isorf.mapper.typemapper;
import com.isorf.pojo.brand;
import com.isorf.pojo.type;
import com.isorf.service.typeservice;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class typeserviceimpl implements typeservice {

    @Autowired
    private typemapper typemapper;

    @Override
    public Boolean updatetype(type type) {
        int result = typemapper.updatetype(type);
        return result > 0;
    }

    @Override
    public Boolean addtype(type type) {
        int result = typemapper.addtype(type);
        if (result > 0) {
            return true;
        } else {
            return false;
        }
    }

    @Override
    public PageInfo<type> pageList(int pageNum, int pageSize) {
        // 使用PageHelper.startPage方法设置分页参数
        PageHelper.startPage(pageNum, pageSize);
        // 查询所有用户数据，此时查询会被自动分页
        List<type> userList = (List<type>) typemapper.pageList();
        // 使用PageInfo包装查询结果，便于页面使用
        return new PageInfo<>(userList);
    }

    @Override
    public Boolean batchDelete(List<Integer> ids) {
        int result = typemapper.batchDelete(ids);
        return result > 0;
    }

    @Override
    public Boolean deletetype(Integer typeid) {
        int result = typemapper.deletetype(typeid); // Fixed: Changed 'id' to 'typeid'
        return result > 0;
    }

    @Override
    public List<type> getalltype() {
        return typemapper.getalltype();
    }
}
